extends Talent

var buffs = globalData.infoDs["g_azurlaneBuffs"]
func init():
	name = "氪金损管"
func _connect():
	sys.main.connect("onBattleStart",self,"run5")

func getEff():
	if lv < 5:
		return 1
	else:
		return 2
	
func run5():
	var num = getEff()
	for i in sys.main.btChas:
		if i.team == 1:
			i.addBuff(b_damageControl.new(num))

# 1 1 1 1 2
func get_info():
	return "一回合内，我方所有角色(除召唤物)都有免疫%d次致命伤害的机会"%[getEff()]

class b_damageControl extends "../../azurlane_ctrl/AzurBuff.gd":
	var num = 2
	func _init(num):
		attInit()
		id = "b_damageControl"
		dispel = 2
		self.num = num
	func _connect():
		masCha.connect("onHurt",self,"_onHurt")
	func _onHurt(atkInfo:AtkInfo):
		if num > 0 and atkInfo.hurtVal > masCha.att.hp and not atkInfo.isMiss:
			atkInfo.hurtVal = 0
			num -= 1
		if num == 0:
			isDel = true
